//
//  NewPopViewController.m
//  HondaPro_2
//
//  Created by ht on 13-7-20.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "NewPopViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "webService.h"
#import "webConfig.h"
#import "AppDelegate.h"
#import "HUD/SVProgressHUD.h"
#import "MyAFNetWorkManager.h"
#import "UIViewController+MJPopupViewController.h"

#define NUMBERS @"0123456789\n"

@interface NewPopViewController ()
{
    BOOL _chooes1;
    BOOL _chooes2;
    BOOL _chooes3;
    BOOL _chooes4;
    BOOL _chooes5;
    BOOL _chooes6;
    BOOL _chooes7;
    BOOL _gWeiChooes;
}

@property(nonatomic,strong)UIButton *chexingBtn;
@property(nonatomic,strong)UILabel *chexingLabel;
@property(nonatomic,strong)UIButton *chexiBtn;
@property(nonatomic,strong)UILabel *chexiLabel;

@end

@implementation NewPopViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        //[self addNotification];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view setFrame:CGRectMake(0, 0, 700, 620)];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.saArray = [NSMutableArray arrayWithCapacity:5];
    self.listRowIndex = [NSMutableArray arrayWithCapacity:5];
    [self fixedTitle];
    [self callTextButton];
    
    
    
    self.saId = @"< 空 >";
    _gWeiChooes = NO;
    
    if (self.editdDataDic) {
        [self editData];
        
    }
}

- (void)viewWillAppear:(BOOL)animated
{
    
}

- (void)editData
{
    NSArray *modelArr = [self readershuDICimform][@"MODEL"];
    NSArray *seriesArr = [self readershuDICimform][@"SERIES"];
    NSArray *laiyuanArr = [self readershuDICimform][@"BOOKING_SOURCE"];
    NSArray *yuyueleixingArr = [self readershuDICimform][@"TM_BOOKING_TYPE"];
    NSArray *guwenArr = [self readershuDICimform][@"SERVICE_ADVISOR"];
    
    NSString *seriesStr;
    NSString *modelStr;
    NSString *laiyuanStr;
    NSString *yuyueleixingStr;
    NSString *guwenStr;
    
    for (NSDictionary *dic in modelArr) {
        if ([dic[@"MODEL_CODE"] isEqualToString:_editdDataDic[@"MODEL"]]) {
            modelStr = dic[@"MODEL_NAME"];
            self.chexingCode = dic[@"MODEL_CODE"];
            [self.chexingBtn setTitle:modelStr forState:UIControlStateNormal];
        }
    }
    
    for (NSDictionary *dic in seriesArr) {
        if ([dic[@"SERIES_CODE"] isEqualToString:_editdDataDic[@"SERIES"]]) {
            seriesStr = dic[@"SERIES_NAME"];
            self.chexiCode = dic[@"SERIES_CODE"];
            [self.chexiBtn setTitle:seriesStr forState:UIControlStateNormal];
        }
    }
    
    NSNumber *laiyuanCode = _editdDataDic[@"RECRUIT_TYPE_NAME"];
    for (NSDictionary *dic in laiyuanArr) {
        if ([dic[@"CODE"] isEqualToString:laiyuanCode.stringValue]) {
            laiyuanStr = dic[@"NAME"];
            self.bookFrom = laiyuanStr;
            self.bookFromCode = dic[@"CODE"];
            [self.bookFromBtn setTitle:laiyuanStr forState:UIControlStateNormal];
        }
    }
    
    for (NSDictionary *dic in yuyueleixingArr) {
        if ([dic[@"BookingTypeCode"] isEqualToString:_editdDataDic[@"BOOKING_TYPE_CODE"]]) {
            yuyueleixingStr = dic[@"BookingTypeName"];
            [self.gWei setTitle:yuyueleixingStr forState:UIControlStateNormal];
            self.gChangNumber = dic[@"BookingTypeCode"];
        }
    }
    
    for (NSDictionary *dic in guwenArr) {
        if ([dic[@"CODE"] isEqualToString:_editdDataDic[@"SA_NAME"]]) {
            guwenStr = dic[@"NAME"];
            [self.fWuConsultant setTitle:guwenStr forState:UIControlStateNormal];
            self.saId = dic[@"CODE"];
        }
    }
    
    self.yYueNumber.text = _editdDataDic[@"PRECONTRACT_ID"];
    self.cPaiNumber.text = _editdDataDic[@"PLATE_NUMBER"];
    self.cJiaNumber.text = _editdDataDic[@"VIN"];
    self.kHuName.text = _editdDataDic[@"CUSTOMER_NAME"];
    self.lXiPhone.text = _editdDataDic[@"MOBILE"];
    self.yHuSpeak.text = _editdDataDic[@"CUSTOMER_DESCRIPTION"];
    [self.beginTime setTitle:_editdDataDic[@"END_TIME"] forState:UIControlStateNormal];
    self.dJiTimeLabel.text = _editdDataDic[@"START_TIME"];
    self.dJPeopleLabel.text = _editdDataDic[@"OPERATOR"];

    self.repairTypeLabel.text=[NSString stringWithFormat:@"%@",_editdDataDic[@"REPAIR_TYPE_CODE"]];
    [self.repairTypeBtn setTitle:[NSString stringWithFormat:@"%@",_editdDataDic[@"REPAIR_TYPE"]] forState:UIControlStateNormal];
    for (UIView *view in self.view.subviews) {
        if (view.tag>=998) {
            view.userInteractionEnabled = YES;
        }
        else{
            view.userInteractionEnabled = NO;
        }
    }
    
//    [self.determineButton removeFromSuperview];
//    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(560, 560, 75, 33)];
//    [btn setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
//    [btn setTitle:@"确  定" forState:UIControlStateNormal];
//    [btn setTintColor:[UIColor blackColor]];
//    btn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    
//    [self.view addSubview:btn];
//    [self.view bringSubviewToFront:btn];
//    [btn addTarget:self action:@selector(determineButton:) forControlEvents:UIControlEventTouchUpInside];
    
    
}


-(void)callTextButton
{
    //预约号
    self.yYueNumber = [[UILabel alloc]initWithFrame:CGRectMake(115, 90, 210, 30)];
    [self.yYueNumber setBackgroundColor:[UIColor clearColor]];
    self.yYueNumber.layer.borderColor = [[UIColor grayColor]CGColor];
    self.yYueNumber.layer.borderWidth = 0.8;
    self.yYueNumber.textColor = [UIColor grayColor];
//    self.yYueNumber.text = [self.modifyDit valueForKey:@"precontractId"];
    [self.yYueNumber setTextAlignment:NSTextAlignmentCenter];
    self.yYueNumber.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:self.yYueNumber];
    
    //车牌号码
    self.cPaiNumber = [[UITextField alloc]initWithFrame:CGRectMake(115, 140, 160, 30)];
    self.cPaiNumber.borderStyle = UITextBorderStyleLine;
    self.cPaiNumber.font = [UIFont fontWithName:@"ArialMT" size:16];
    self.cPaiNumber.textColor = [UIColor grayColor];
//    self.cPaiNumber.text = [self.modifyDit valueForKey:@"plateNumber"];
    self.cPaiNumber.text = @"";
//    self.cPaiNumber.clearsOnBeginEditing = YES;
    [self.cPaiNumber setPlaceholder:@"查询条件大于两位"];
    [self.cPaiNumber setTextAlignment:NSTextAlignmentCenter];
    self.cPaiNumber.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self.view addSubview:self.cPaiNumber];
    //车牌查询
    self.carPlateCxun = [[UIButton alloc]initWithFrame:CGRectMake(280, 138, 47, 35)];
    [self.carPlateCxun setTitle:@"🔍" forState:UIControlStateNormal];
    [self.carPlateCxun setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //    [self.carPlateCxun setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
    self.carPlateCxun.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:23];
    [self.carPlateCxun addTarget:self action:@selector(carPlateCxun:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.carPlateCxun];
    
    //车型
    UILabel *label18 = [[UILabel alloc]initWithFrame:CGRectMake(115, 190, 210, 30)];
    [label18 setBackgroundColor:[UIColor whiteColor]];
    label18.layer.borderColor = [[UIColor grayColor]CGColor];
    label18.layer.borderWidth = 0.8;
    [self.view addSubview:label18];
    self.chexiBtn = [[UIButton alloc]initWithFrame:CGRectMake(116, 191, 208, 28)];
    [self.chexiBtn setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.chexiBtn addTarget:self action:@selector(getCheXi:) forControlEvents:UIControlEventTouchUpInside];
    [self.chexiBtn setTitle:@"请选择" forState:UIControlStateNormal];
    self.chexiBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.chexiBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.view addSubview:self.chexiBtn];
    
    //车系
    UILabel *label19 = [[UILabel alloc]initWithFrame:CGRectMake(430, 190, 210, 30)];
    [label19 setBackgroundColor:[UIColor whiteColor]];
    label19.layer.borderColor = [[UIColor grayColor]CGColor];
    label19.layer.borderWidth = 0.8;
    [self.view addSubview:label19];
    self.chexingBtn = [[UIButton alloc]initWithFrame:CGRectMake(431, 191, 208, 28)];
    [self.chexingBtn setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.chexingBtn addTarget:self action:@selector(getCheXing:) forControlEvents:UIControlEventTouchUpInside];
    [self.chexingBtn setTitle:@"请选择" forState:UIControlStateNormal];
    self.chexingBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.chexingBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.view addSubview:self.chexingBtn];
    
    //客户名称
    self.kHuName = [[UITextField alloc]initWithFrame:CGRectMake(115, 240, 210, 30)];
    self.kHuName.borderStyle = UITextBorderStyleLine;
    self.kHuName.font = [UIFont fontWithName:@"ArialMT" size:16];
    self.kHuName.textColor = [UIColor grayColor];
    [self.kHuName setTextAlignment:NSTextAlignmentCenter];
    self.kHuName.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self.view addSubview:self.kHuName];
    //备注
    self.yHuSpeak = [[UITextView alloc]initWithFrame:CGRectMake(115, 320, 525, 65)];
    self.yHuSpeak.font = [UIFont fontWithName:@"ArialMT" size:15];
    self.yHuSpeak.layer.borderColor = [[UIColor grayColor]CGColor];
    self.yHuSpeak.layer.borderWidth = 0.8;
    self.yHuSpeak.textColor = [UIColor grayColor];
    self.yHuSpeak.tag = 998;
//    self.yHuSpeak.text = [self.modifyDit valueForKey:@"customerDescription"];
    [self.view addSubview:self.yHuSpeak];
    
    //修理类型
    self.xLiType = [[UIView alloc]initWithFrame:CGRectMake(115, 320, 525, 75)];
    self.xLiType.layer.borderColor = [[UIColor grayColor]CGColor];
    self.xLiType.layer.borderWidth = 0.8;
    //[self.view addSubview:self.xLiType];
    
    //工位
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(115, 410, 208, 30)];
    [label2 setBackgroundColor:[UIColor whiteColor]];
    label2.layer.borderColor = [[UIColor grayColor]CGColor];
    label2.layer.borderWidth = 0.8;
    [self.view addSubview:label2];
    self.gWei = [[UIButton alloc]initWithFrame:CGRectMake(116, 411, 206, 28)];
    [self.gWei setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.gWei addTarget:self action:@selector(gWei:) forControlEvents:UIControlEventTouchUpInside];
    [self.gWei setTitle:@"请选择" forState:UIControlStateNormal];
    self.gWei.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.gWei setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    self.gWei.tag = 1000;
    self.gChangNumber = @"0";
    [self.view addSubview:self.gWei];
    
    //工位员工名字
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(225, 410, 100, 30)];
    [label3 setBackgroundColor:[UIColor whiteColor]];
    label3.layer.borderColor = [[UIColor grayColor]CGColor];
    label3.layer.borderWidth = 0.8;
    //[self.view addSubview:label3];
    self.gWeiName = [[UIButton alloc]initWithFrame:CGRectMake(226, 411, 98, 28)];
    [self.gWeiName setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.gWeiName addTarget:self action:@selector(gWeiName:) forControlEvents:UIControlEventTouchUpInside];
    [self.gWeiName setTitle:@"请选择" forState:UIControlStateNormal];
    self.gWeiName.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.gWeiName setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.gWeiName setTag:1];
    //[self.view addSubview:self.gWeiName];
    
    //预约时间
    NSTimeInterval secondsPerDay = 24*60*60;
    NSDate *tomorrow = [[NSDate alloc] initWithTimeIntervalSinceNow:secondsPerDay];
    NSDateFormatter *dateformat=[[NSDateFormatter alloc] init];
    [dateformat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSString *str = [dateformat stringFromDate:tomorrow];
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(115, 460, 210, 30)];
    [label4 setBackgroundColor:[UIColor whiteColor]];
    label4.layer.borderColor = [[UIColor grayColor]CGColor];
    label4.layer.borderWidth = 0.8;
    [self.view addSubview:label4];
    self.beginTime = [[UIButton alloc]initWithFrame:CGRectMake(116, 461, 208, 28)];
    [self.beginTime setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.beginTime addTarget:self action:@selector(beginTime:) forControlEvents:UIControlEventTouchUpInside];
    [self.beginTime setTitle:str forState:UIControlStateNormal];
    self.beginTime.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.beginTime setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    self.beginTime.tag = 1001;
    [self.view addSubview:self.beginTime];
    
    //登记人
    self.dJPeopleLabel = [[UILabel alloc]initWithFrame:CGRectMake(115, 510, 210, 30)];
    self.dJPeopleLabel.backgroundColor = [[UIColor alloc]initWithRed:248.00/255 green:248.00/255 blue:248.00/255 alpha:1];
    self.dJPeopleLabel.layer.borderColor = [[UIColor grayColor]CGColor];
    self.dJPeopleLabel.layer.borderWidth = 0.8;
    self.dJPeopleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.dJPeopleLabel setTextAlignment:NSTextAlignmentCenter];
    self.dJPeopleLabel.textColor = [UIColor grayColor];
//    AppDelegate *myApp = [[UIApplication sharedApplication] delegate];
    self.dJPeopleLabel.text =[[NSUserDefaults standardUserDefaults] objectForKey:@"USER_NAME"];
    [self.view addSubview:self.dJPeopleLabel];
    
    //来源类型
    UILabel *label31 = [[UILabel alloc]initWithFrame:CGRectMake(430, 90, 210, 30)];
    [label31 setBackgroundColor:[UIColor whiteColor]];
    label31.layer.borderColor = [[UIColor grayColor] CGColor];
    label31.layer.borderWidth = 0.8;
    [self.view addSubview:label31];
    self.bookFromBtn = [[UIButton alloc]initWithFrame:CGRectMake(431, 91, 208, 28)];
    [self.bookFromBtn setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.bookFromBtn addTarget:self action:@selector(getBookFrom:) forControlEvents:UIControlEventTouchUpInside];
    [self.bookFromBtn setTitle:@"请选择" forState:UIControlStateNormal];
    self.bookFromBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.bookFromBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.bookFromBtn setTag:9];
    [self.view addSubview:self.bookFromBtn];
    
//    self.yYueTypeLabel = [[UILabel alloc]initWithFrame:CGRectMake(430, 90, 210, 30)];
//    [self.yYueTypeLabel setBackgroundColor:[UIColor clearColor]];
//    self.yYueTypeLabel.layer.borderColor = [[UIColor grayColor]CGColor];
//    self.yYueTypeLabel.layer.borderWidth = 0.8;
//    self.yYueTypeLabel.text = @"用户来电";
//    self.yYueTypeLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
//    [self.yYueTypeLabel setTextAlignment:NSTextAlignmentCenter];
//    self.yYueTypeLabel.textColor = [UIColor grayColor];
//    [self.view addSubview:self.yYueTypeLabel];
    
    //车架号
    self.cJiaNumber = [[UITextField alloc]initWithFrame:CGRectMake(430, 140, 210, 30)];
    self.cJiaNumber.borderStyle = UITextBorderStyleLine;
    self.cJiaNumber.font = [UIFont fontWithName:@"ArialMT" size:16];
    self.cJiaNumber.textColor = [UIColor grayColor];
    //    self.cJiaNumber.text = [self.modifyDit valueForKey:@"mobile"];
    [self.cJiaNumber setTextAlignment:NSTextAlignmentCenter];
    self.cJiaNumber.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self.view addSubview:self.cJiaNumber];
    
    //联系电话
    self.lXiPhone = [[UITextField alloc]initWithFrame:CGRectMake(430, 240, 210, 30)];
    self.lXiPhone.borderStyle = UITextBorderStyleLine;
    self.lXiPhone.font = [UIFont fontWithName:@"ArialMT" size:16];
    self.lXiPhone.textColor = [UIColor grayColor];
//    self.lXiPhone.text = [self.modifyDit valueForKey:@"mobile"];
    [self.lXiPhone setTextAlignment:NSTextAlignmentCenter];
    self.lXiPhone.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    self.lXiPhone.keyboardType = UIKeyboardTypeNumberPad;
    self.lXiPhone.clearsOnBeginEditing = YES;
    self.lXiPhone.delegate = self;
    [self.view addSubview:self.lXiPhone];
    
    //服务顾问
    UILabel *label8 = [[UILabel alloc]initWithFrame:CGRectMake(430, 410, 210, 30)];
    [label8 setBackgroundColor:[UIColor whiteColor]];
    label8.layer.borderColor = [[UIColor grayColor]CGColor];
    label8.layer.borderWidth = 0.8;
    [self.view addSubview:label8];
    self.fWuConsultant = [[UIButton alloc]initWithFrame:CGRectMake(431, 411, 208, 28)];
    [self.fWuConsultant setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.fWuConsultant addTarget:self action:@selector(fWuConsultant:) forControlEvents:UIControlEventTouchUpInside];
    [self.fWuConsultant setTitle:@"请选择" forState:UIControlStateNormal];
    self.fWuConsultant.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.fWuConsultant setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    self.fWuConsultant.tag = 1002;
    [self.view addSubview:self.fWuConsultant];
    
    
    //维修分类
    UILabel *repairTypeLabel = [[UILabel alloc]initWithFrame:CGRectMake(430, 460, 210, 30)];
    [repairTypeLabel setBackgroundColor:[UIColor whiteColor]];
    repairTypeLabel.layer.borderColor = [[UIColor grayColor]CGColor];
    self.repairTypeLabel=repairTypeLabel;
    repairTypeLabel.layer.borderWidth = 0.8;
    [self.view addSubview:repairTypeLabel];
    self.repairTypeBtn = [[UIButton alloc]initWithFrame:CGRectMake(431, 461, 208, 28)];
    [self.repairTypeBtn setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    //fWuConsultant
    [self.repairTypeBtn addTarget:self action:@selector(clickRepairType:) forControlEvents:UIControlEventTouchUpInside];
    [self.repairTypeBtn setTitle:@"请选择" forState:UIControlStateNormal];
    self.repairTypeBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.repairTypeBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    self.repairTypeBtn.tag = 1002;
    [self.view addSubview:self.repairTypeBtn];
    
    //结束时间
    UILabel *label9 = [[UILabel alloc]initWithFrame:CGRectMake(430, 460, 210, 30)];
    [label9 setBackgroundColor:[UIColor whiteColor]];
    label9.layer.borderColor = [[UIColor grayColor]CGColor];
    label9.layer.borderWidth = 0.8;
    //[self.view addSubview:label9];
    self.endTime = [[UIButton alloc]initWithFrame:CGRectMake(431, 461, 208, 28)];
    [self.endTime setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.endTime addTarget:self action:@selector(endTime:) forControlEvents:UIControlEventTouchUpInside];
    [self.endTime setTitle:@"< 空 >" forState:UIControlStateNormal];
    self.endTime.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.endTime setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    //[self.view addSubview:self.endTime];
    
    //登记时间
    NSDate * senddate=[NSDate date];
    NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSString * locationString=[dateformatter stringFromDate:senddate];
    self.dJiTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(430, 510, 210, 30)];
    self.dJiTimeLabel.backgroundColor =[[UIColor alloc]initWithRed:248.00/255 green:248.00/255 blue:248.00/255 alpha:1];
    self.dJiTimeLabel.layer.borderColor = [[UIColor grayColor]CGColor];
    self.dJiTimeLabel.layer.borderWidth = 0.8;
    self.dJiTimeLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.dJiTimeLabel setTextAlignment:NSTextAlignmentCenter];
    self.dJiTimeLabel.textColor = [UIColor grayColor];
    self.dJiTimeLabel.text = locationString;
    [self.view addSubview:self.dJiTimeLabel];
    
#pragma mark - 确定按钮
    self.determineButton = [[UIButton alloc]initWithFrame:CGRectMake(560, 560, 75, 33)];//470, 560, 75, 33
    [self.determineButton setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
    [self.determineButton setTitle:@"确  定" forState:UIControlStateNormal];
    [self.determineButton setTintColor:[UIColor whiteColor]];
    self.determineButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.determineButton addTarget:self action:@selector(determineButton:) forControlEvents:UIControlEventTouchUpInside];
    self.determineButton.tag = 999;
    [self.view addSubview:self.determineButton];
    
    self.cancelButton = [[UIButton alloc]initWithFrame:CGRectMake(560, 560, 75, 33)];
    [self.cancelButton setTitle:@"取 消" forState:UIControlStateNormal];
    [self.cancelButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.cancelButton setBackgroundImage:[UIImage imageNamed:@"改-灰but.png"] forState:UIControlStateNormal];
    self.cancelButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.cancelButton addTarget:self action:@selector(cancelButton:) forControlEvents:UIControlEventTouchUpInside];
    //[self.view addSubview:self.cancelButton];
#pragma mark - 查看派工信息    
    self.toViewButton = [[UIButton alloc]initWithFrame:CGRectMake(460, 560, 85, 35)];
    [self.toViewButton setBackgroundImage:[UIImage imageNamed:@"改-灰but.png"] forState:UIControlStateNormal];
    [self.toViewButton setTitle:@"查看工位信息" forState:UIControlStateNormal];
    [self.toViewButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    self.toViewButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:13];
    [self.toViewButton addTarget:self action:@selector(toViewButton:) forControlEvents:UIControlEventTouchUpInside];
    //[self.view addSubview:self.toViewButton];
    
    [self stateOfRepairChoose];
}

-(void)GetRepairCustomerListByPlateNumber:(NSNotification *)notifcation
{
    NSMutableDictionary *Json= [NSJSONSerialization JSONObjectWithData:(NSData*)notifcation.object options:NSJSONReadingMutableLeaves error:Nil];
    self.listRowIndex = [Json objectForKey:@"customerList"];
    [self searchCarPlateView];
    [self.searchPlateView reloadData];
    [SVProgressHUD dismiss];
}
#pragma mark - 查询车牌弹出窗口
-(void)searchCarPlateView
{
    self.popSearchView = [[UIView alloc]initWithFrame:CGRectMake(20, 20, 700-20-20, 620-20-20)];
    [self.popSearchView setBackgroundColor:[UIColor whiteColor]];
    // [self addSubview:self.popSearchView];
    
    self.searchPlateView = [[UITableView alloc]initWithFrame:CGRectMake(20, 100, self.popSearchView.frame.size.width-20-20, self.popSearchView.frame.size.height-100-70)];
    [self.searchPlateView setDelegate:self];
    [self.searchPlateView setDataSource:self];
    [self.popSearchView addSubview:self.searchPlateView];
    [self.view addSubview:self.popSearchView];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, 55, 650, 40)];
    label.text = @"       车牌号码                   车架号                           车系                          车型";
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor grayColor];
    label.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.popSearchView addSubview:label];
    
    UIButton *doneBut = [[UIButton alloc]initWithFrame:CGRectMake(563, 5, 75, 35)];
    [doneBut setTitle:@"取 消" forState:UIControlStateNormal];
    [doneBut setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [doneBut setBackgroundImage:[UIImage imageNamed:@"改-灰but.png"] forState:UIControlStateNormal];
    doneBut.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [doneBut addTarget:self action:@selector(doneBut:) forControlEvents:UIControlEventTouchUpInside];
    [self.popSearchView addSubview:doneBut];
}
-(void)doneBut:(id)sender
{
    [self.popSearchView removeFromSuperview];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.listRowIndex count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    static NSString *indetfire = @"cell";
    SearchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indetfire];
    if(nil == cell)
    {
        cell = [[SearchTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetfire];
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    
    NSArray *zidianArr1=[self readershuDICimform][@"MODEL"];
    NSArray *zidianArr2=[self readershuDICimform][@"SERIES"];
    
    for(NSDictionary *dic in zidianArr2)
    {
        if ([dic[@"SERIES_CODE"] isEqualToString:[[self.listRowIndex objectAtIndex:row]objectForKey:@"SERIES"]]) {
            cell.carFrame.text = dic[@"SERIES_NAME"];
            break;
        }
    }
    
    for(NSDictionary *dic in zidianArr1)
    {
        if ([dic[@"MODEL_CODE"] isEqualToString:[[self.listRowIndex objectAtIndex:row]objectForKey:@"MODEL"]]) {
            cell.phone.text = dic[@"MODEL_NAME"];
            break;
        }
    }
    
    cell.plateNumber.text = [[self.listRowIndex objectAtIndex:row]objectForKey:@"LICENSE"];
    cell.customerName.text = [[self.listRowIndex objectAtIndex:row]objectForKey:@"VIN"];
    
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 45;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row%2 == 1)
    {
        cell.backgroundColor = [UIColor whiteColor];
    }
    else
    {
        cell.backgroundColor = [[UIColor alloc]initWithRed:226.00/255 green:226.00/255 blue:226.00/255 alpha:1];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSDictionary *dics = [self.listRowIndex objectAtIndex:indexPath.row];
    
    self.kHuName.text = [dics objectForKey:@"OWNER_NAME"];
    self.lXiPhone.text = [dics objectForKey:@"MOBILE"];
    self.cPaiNumber.text = [dics objectForKey:@"LICENSE"];
    self.cJiaNumber.text = [dics objectForKey:@"VIN"];
    
    NSArray *zidianArr1=[self readershuDICimform][@"MODEL"];
    NSArray *zidianArr2=[self readershuDICimform][@"SERIES"];
    
    for(NSDictionary *dic in zidianArr2)
    {
        if ([dic[@"SERIES_CODE"] isEqualToString:dics[@"SERIES"]]) {
            self.chexiCode = dic[@"SERIES_CODE"];
            [self.chexiBtn setTitle:dic[@"SERIES_NAME"] forState:UIControlStateNormal];
            break;
        }
    }
    
    for(NSDictionary *dic in zidianArr1)
    {
        if ([dic[@"MODEL_CODE"] isEqualToString:dics[@"MODEL"]]) {
            self.chexingCode = dic[@"MODEL_CODE"];
            [self.chexingBtn setTitle:dic[@"MODEL_NAME"] forState:UIControlStateNormal];
            break;
        }
    }
    
    
    [self.popSearchView removeFromSuperview];
}

#pragma mark - 车型查询按钮的回调
- (void)getCheXing:(id)sender
{
    [self.view endEditing:YES];
    if (self.chexiCode.length==0) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"请选择车系" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
        return;
    }
    
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.bookFromBtn.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(0, 10, 105, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    
    NSArray *zidianArr=[self readershuDICimform][@"MODEL"];
    
    NSMutableArray *chexingArr = [[NSMutableArray alloc] init];
    for(NSDictionary *dic in zidianArr)
    {
        NSString *str = dic[@"SERIES_CODE"];
        if ([str isEqualToString:self.chexiCode]) {
            [chexingArr addObject:dic[@"MODEL_NAME"]];
        }
    }
    
    contentCon.list = chexingArr;
    [contentCon.myTableView reloadData];
}

#pragma mark - 车系查询按钮的回调
- (void)getCheXi:(id)sender
{
    [self.view endEditing:YES];
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.bookFromBtn.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(0, 10, 105, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    
    NSArray *zidianArr=[self readershuDICimform][@"SERIES"];
    NSMutableArray *chexiArr = [[NSMutableArray alloc] init];
    for(NSDictionary *dic in zidianArr)
    {
        [chexiArr addObject:dic[@"SERIES_NAME"]];
    }
    
    contentCon.list = chexiArr;
    [contentCon.myTableView reloadData];
}

#pragma mark - 车牌查询按钮的回调
-(void)carPlateCxun:(id)sender
{
    [self.view endEditing:YES];
    if(self.cPaiNumber.text.length == 0)
    {
        [SVProgressHUD showErrorWithStatus:@"请填写车牌号"];
        return;
    }
    
    
    [SVProgressHUD showWithStatus:@"请等待...."];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:5];
    [dic setValue:self.cPaiNumber.text forKey:@"PLATE_NUMBER"];
    [MyAFNetWorkManager postWithParam:dic andAction:@"QUERY_VEHICLE" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
        [SVProgressHUD dismiss];
        if (!error) {
            NSLog(@"预约查询车牌号：%@",obj);
            [self.listRowIndex removeAllObjects];
            [self.listRowIndex setArray:(NSArray *)[obj objectForKey:@"TM_VEHICLE"]];
            [self searchCarPlateView];
        }
        else{
            [SVProgressHUD showErrorWithStatus:error.localizedDescription];
        }
    }];
}

#pragma mark - 来源按钮的回调
- (void)getBookFrom:(id)sender
{
    [self.view endEditing:YES];
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.bookFromBtn.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(0, 10, 105, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    
    NSArray *zidianArr=[self readershuDICimform][@"BOOKING_SOURCE"];
    self.gChangXZ = [[NSMutableArray alloc] init];
    for(NSDictionary *dic in zidianArr)
    {
        [self.gChangXZ addObject:dic[@"NAME"]];
    }
    
    
    contentCon.list = self.gChangXZ;
    [contentCon.myTableView reloadData];
}

#pragma mark - 预约类型选择按钮的回调
-(void)gWei:(id)sender
{
    _gWeiChooes = YES;
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.gWei.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(0, 10, 105, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSArray *zidianArr=[self readershuDICimform][@"TM_BOOKING_TYPE"];
    self.gChangXZ = [[NSMutableArray alloc] init];
    for(NSDictionary *dic in zidianArr)
    {
        [self.gChangXZ addObject:dic[@"BookingTypeName"]];
    }
    
    
    contentCon.list = self.gChangXZ;
    [contentCon.myTableView reloadData];
}
#pragma mark - 工位员工选择按钮的回调
-(void)gWeiName:(id)sender
{
    contentCon.list=nil;
    webService *webcon = [[webService alloc] init];
    webcon.methodName = GETWORKSTATIONLIST;
    NSMutableArray *arry = [NSMutableArray arrayWithObjects:@"workshopType",self.gChangNumber,nil];

    [webcon commonGetSharedRequest:GETWORKSTATIONLIST wsparas:arry];
    
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    UIPopoverController *popCons = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [popCons setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [popCons setPopoverContentSize:CGSizeMake(self.gWeiName.frame.size.width, 280)];
    [popCons presentPopoverFromRect:CGRectMake(0, 10, 105, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)getworkStationListOne:(NSNotification*)notification
{
    NSDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData*)notification.object options:NSJSONReadingMutableLeaves error:Nil];
    self.workStationArray = [theJson objectForKey:@"workStationList"];
    NSMutableArray *gWeiArray = [[NSMutableArray alloc]init];
    for(int i=0;i<[[theJson objectForKey:@"workStationList"]count];i++)
    {
        [gWeiArray addObject:[[[theJson objectForKey:@"workStationList"]objectAtIndex:i]objectForKey:@"workStationName"]];
    }
    contentCon.list = nil;
    contentCon.list = gWeiArray;
    [contentCon.myTableView reloadData];
}

#pragma mark - 开始时间选择按钮的回调
-(void)beginTime:(id)sender
{
    _chooseDate = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 200)];
    _chooseDate.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    _chooseDate.datePickerMode = UIDatePickerModeDateAndTime;
    [_chooseDate addTarget:self action:@selector(dateChanged2:) forControlEvents:UIControlEventValueChanged];
    //
    UIViewController *panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:_chooseDate];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = _chooseDate.frame.size;
    
    [self.popCon presentPopoverFromRect:CGRectMake(100, 0, 0, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged2:(id)sender
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    //NSData *data = [NSString stringWithFormat:@"%@",[formatter stringFromDate:_chooseDate.date]];
    [self.beginTime setTitle:[formatter stringFromDate:_chooseDate.date] forState:UIControlStateNormal];
}

-(void)clickRepairType:(UIButton*)sender{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.fWuConsultant.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(44, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSArray *zidianArr=[self readershuDICimform][@"TM_REPAIR_TYPE_CODE"];
    NSMutableArray *fuwuguwenArr = [NSMutableArray arrayWithCapacity:5];
    [self.saArray removeAllObjects];
    [self.saArray setArray:zidianArr];
    
    for(NSDictionary *dic in zidianArr)
    {
        [fuwuguwenArr addObject:dic[@"NAME"]];
        //[self.saArray addObject:dic[@"CODE"]];
    }
    contentCon.list = fuwuguwenArr;
    [contentCon.myTableView reloadData];
}
#pragma mark - 服务顾问选择按钮的回调
-(void)fWuConsultant:(id)sender
{
//    webService *webcon = [[webService alloc] init];
//    webcon.methodName = GETSANAMELIST;
//    [webcon commonGetSharedRequest:GETSANAMELIST wsparas:Nil];
    
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.fWuConsultant.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(44, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSArray *zidianArr=[self readershuDICimform][@"SERVICE_ADVISOR"];
    NSMutableArray *fuwuguwenArr = [NSMutableArray arrayWithCapacity:5];
    [self.saArray removeAllObjects];
    [self.saArray setArray:zidianArr];
    
    for(NSDictionary *dic in zidianArr)
    {
        [fuwuguwenArr addObject:dic[@"NAME"]];
        //[self.saArray addObject:dic[@"CODE"]];
    }
    contentCon.list = fuwuguwenArr;
    [contentCon.myTableView reloadData];
}


-(NSMutableDictionary *)readershuDICimform
{
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path=[paths objectAtIndex:0];
    NSString *str=[path stringByAppendingPathComponent:@"Dic.text"];
    dic=[NSMutableDictionary dictionaryWithContentsOfFile:str];
    //nslog(@"%@",dic);
    return dic;
}

-(void)getSaName:(NSNotification*)notification{

    NSDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData*)notification.object options:NSJSONReadingMutableLeaves error:Nil];
    self.saArray = [theJson objectForKey:@"results"];
    NSMutableArray *carTypeArray=[[NSMutableArray alloc] init];
    [carTypeArray addObject:@"< 空 >"];
    
    for (int i=0; i<[[theJson objectForKey:@"results"] count]; i++) {
        
        [carTypeArray addObject: [[[theJson objectForKey:@"results"] objectAtIndex:i] objectForKey:@"saName"]];
    }
    contentCon.list = nil;
    contentCon.list = carTypeArray;
    
    [contentCon.myTableView reloadData];
}
#pragma mark - 弹出回调方法
-(void)selectDelegate:(NSInteger)row btn:(UIButton *)btn
{
    if (btn==self.bookFromBtn) {
        NSArray *zidianArr=[self readershuDICimform][@"BOOKING_SOURCE"];
        NSDictionary *bookDic = zidianArr[row];
        self.bookFromCode = bookDic[@"CODE"];
    }
    
    if (btn==self.fWuConsultant)
    {
        self.saId = [[self.saArray objectAtIndex:row] objectForKey:@"CODE"];
//        if (row > 0)
//        {
//            self.saId = [[self.saArray objectAtIndex:row-1] objectForKey:@"CODE"];
//        }
    }
    
    if (btn==self.chexingBtn) {
        NSArray *zidianArr=[self readershuDICimform][@"MODEL"];
        NSDictionary *chexi = zidianArr[row];
        self.chexingCode = chexi[@"MODEL_CODE"];
    }
    
    if (btn==self.chexiBtn) {
        NSArray *zidianArr=[self readershuDICimform][@"SERIES"];
        NSDictionary *chexi = zidianArr[row];
        self.chexiCode = chexi[@"SERIES_CODE"];
        
        self.chexingCode = nil;
        [self.chexingBtn setTitle:@"" forState:UIControlStateNormal];
    }
    
    if(btn == self.gWeiName)
    {
        self.workStationNameId = [[self.workStationArray objectAtIndex:row]objectForKey:@"workStationId"];
    }

    
    if(btn == self.gWei)
    {
        //查询登录后下发的字典文件，表名TM_BOOKING_TYPE 字段BOOKING_TYPE_CODE  BOOKING_TYPE_NAME
        self.gWeiName.titleLabel.text = @"请选择";
        NSArray *zidianArr=[self readershuDICimform][@"TM_BOOKING_TYPE"];
        NSDictionary *bookDic = zidianArr[row];
        self.gChangNumber = bookDic[@"BookingTypeCode"];
        
    }
    if(btn==self.repairTypeBtn){
        //维护类型
         self.repairTypeLabel.text = [[self.saArray objectAtIndex:row] objectForKey:@"CODE"];
       
    }

    [self.popCon dismissPopoverAnimated:YES];
    self.popCon = nil;
}

#pragma mark - 结束时间选择按钮的回调
-(void)endTime:(id)sender
{
    _chooseDate = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 200)];
    _chooseDate.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    _chooseDate.datePickerMode = UIDatePickerModeDateAndTime;
    [_chooseDate addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
    //
    UIViewController *panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:_chooseDate];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = _chooseDate.frame.size;
    
    [self.popCon presentPopoverFromRect:CGRectMake(100, 0, 0, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged:(id)sender
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    //NSString *data = [NSString stringWithFormat:@"%@",[formatter stringFromDate:_chooseDate.date]];
    [self.endTime setTitle:[formatter stringFromDate:_chooseDate.date] forState:UIControlStateNormal];
}

-(void)cancelButton:(id)sender
{
    [self dismissWithCompletion:nil];
}

#pragma mark - 确定按钮的回调
-(void)determineButton:(id)sender
{
    if(!self.kHuName.text.length)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择客户名称" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
        return;
    }
    else if(!self.lXiPhone.text.length)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请输入联系电话" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
        return;
    }
//    else if(self.yHuSpeak.text == nil)
//    {
//        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请输入备注" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
//        [alertView show];
//        return;
//    }
    else if(self.cPaiNumber.text.length <=2)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请填写正确车牌号" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
        return;
    }else if(!self.repairTypeLabel.text.length){
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择维修分类" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
        return;
        
    }
    else if(!self.beginTime.titleLabel.text.length){
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择预约时间" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
        return;
        
    }else if([self.fWuConsultant.titleLabel.text isEqualToString:@"请选择"]&&![self.fWuConsultant.titleLabel.text isEqualToString:@"< 空 >"]){
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择服务顾问" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
        return;
        
    }else if(!self.cPaiNumber.text.length){
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择车牌号码" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
        return;
        
    }
    else
    {
        [self tijiaoDictionary];
        [SVProgressHUD showWithStatus:@"加载中..."];
        [MyAFNetWorkManager postWithParam:self.addPopDit andAction:@"MAINTAIN_BOOKING_ORDER_FOR_PAD" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
            [SVProgressHUD dismiss];
            if (!error) {
                NSLog(@"新增预约查询：%@",obj);
                if ([[NSString stringWithFormat:@"%@",obj[@"SUCCESS"]]  isEqualToString:@"0"]) {
                    [SVProgressHUD showErrorWithStatus:@"操作失败,请重试"];
                    return ;
                }
                if (self.editdDataDic) {
                    [SVProgressHUD showSuccessWithStatus:@"修改成功"];
                }
                else{
                    [SVProgressHUD showSuccessWithStatus:@"新增成功"];
                }
                
                self.yYueNumber.text = obj[@"BOOKING_ORDER_NO_RETURN"];
                [self dismissWithCompletion:nil];
                if ([self.delegate respondsToSelector:@selector(addNewSuccess)]) {
                    [self.delegate addNewSuccess];
                }
            }
            else{
                [SVProgressHUD showErrorWithStatus:error.localizedDescription];
            }
        }];
    }
}

-(void)addPrecontractManage:(NSNotification*)notification
{
    NSMutableDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData *)notification.object options:NSJSONReadingMutableLeaves error:nil];
    if([[theJson valueForKey:@"error_code"] intValue])
    {
//        NSLog(@"*!*!*!*!*!%@",[theJson valueForKey:@"error_code"]);
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[theJson valueForKey:@"error_msg"] message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
        [SVProgressHUD dismiss];
        return;
    }
    else
    {
        [SVProgressHUD dismiss];
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"保存成功！" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }

}
#pragma mark - 组织要提交数据
-(void)tijiaoDictionary
{
    self.addPopDit = [[NSMutableDictionary alloc]initWithCapacity:10];
    if (self.editdDataDic) {
        [self.addPopDit setValue:self.editdDataDic[@"PRECONTRACT_ID"] forKey:@"BOOKING_ORDER_NO"];
    }
    
    //车牌号码
    [self.addPopDit setValue:[self transUTF8String:self.cPaiNumber.text] forKey:@"PLATE_NUMBER"];
    //车架号
    [self.addPopDit setValue:self.cJiaNumber.text forKey:@"VIN"];
    //客户名称
    [self.addPopDit setValue:[self transUTF8String:self.kHuName.text] forKey:@"CUSTOMER_NAME"];
    //联系电话
    [self.addPopDit setValue:self.lXiPhone.text forKey:@"MOBILE"];
    //用户称述
    [self.addPopDit setValue:[self transUTF8String:self.yHuSpeak.text] forKey:@"CUSTOMER_STATEMENTS"];
    //招揽类型
    [self.addPopDit setValue:self.gChangNumber forKey:@"BOOKING_TYPE_CODE"];
    //来源
    [self.addPopDit setValue:self.bookFromCode forKey:@"RECRUIT_TYPE_NAME"];
    //车型
    [self.addPopDit setValue:self.chexingCode forKey:@"MODEL"];
    //车系
    [self.addPopDit setValue:self.chexiCode forKey:@"SERIES"];
    //维修分类
    [self.addPopDit setObject:self.repairTypeLabel.text forKey:@"REPAIR_TYPE"];
    //服务顾问
    if(![self.fWuConsultant.titleLabel.text isEqualToString:@"请选择"]&&![self.fWuConsultant.titleLabel.text isEqualToString:@"< 空 >"])
    {
        [self.addPopDit setValue:self.saId forKey:@"SA_ID"];
    }
    
    //登记人
    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
    
    [self.addPopDit setValue:[user objectForKey:@"EMPLOYEE_NO"] forKey:@"OPERATOR"];
    
    //登记时间
    [self.addPopDit setValue:self.dJiTimeLabel.text forKey:@"CREATE_DATE"];
    
    //预约时间
    [self.addPopDit setValue:self.beginTime.titleLabel.text forKey:@"BOOKING_COME_TIME"];
    //结束时间
    //[self.addPopDit setObject:self.endTime.titleLabel.text forKey:@"endTime"];
}

- (NSString *)transUTF8String:(NSString *)needTrans
{
    return [needTrans stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}

#pragma mark - 维修状态选择
-(void)stateOfRepairChoose
{
    //首次保养
    self.firstChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.firstChoose setFrame:CGRectMake(10, 5, 30, 31)];
    [self.firstChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.firstChoose addTarget:self action:@selector(firstChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.firstChoose];
    //年检保养
    self.nJianChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.nJianChoose setFrame:CGRectMake(160, 5, 30, 31)];
    [self.nJianChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.nJianChoose addTarget:self action:@selector(nJianChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.nJianChoose];
    //钣金
    self.bJinChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.bJinChoose setFrame:CGRectMake(300, 5, 30, 31)];
    [self.bJinChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.bJinChoose addTarget:self action:@selector(bJinChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.bJinChoose];
    //精品
    self.jPinChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.jPinChoose setFrame:CGRectMake(410, 5, 30, 31)];
    [self.jPinChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.jPinChoose addTarget:self action:@selector(jPinChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.jPinChoose];
    //定期保养
    self.dQiChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.dQiChoose setFrame:CGRectMake(10, 40, 30, 31)];
    [self.dQiChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.dQiChoose addTarget:self action:@selector(dQiChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.dQiChoose];
    //一般修理
    self.yBanChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.yBanChoose setFrame:CGRectMake(160, 40, 30, 31)];
    [self.yBanChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.yBanChoose addTarget:self action:@selector(yBanChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.yBanChoose];
    //喷漆
    self.pQiChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.pQiChoose setFrame:CGRectMake(300, 40, 30, 31)];
    [self.pQiChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.pQiChoose addTarget:self action:@selector(pQiChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.pQiChoose];
    
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(45, 5, 80, 35)];
    label1.text = @"首保";
    label1.backgroundColor = [UIColor clearColor];
    label1.textColor = [UIColor grayColor];
    label1.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label1];
    
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(195, 5, 80, 35)];
    label2.text = @"年检保养";
    label2.backgroundColor = [UIColor clearColor];
    label2.textColor = [UIColor grayColor];
    label2.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label2];
    
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(335, 5, 80, 35)];
    label3.text = @"钣金";
    label3.backgroundColor = [UIColor clearColor];
    label3.textColor = [UIColor grayColor];
    label3.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label3];
    
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(445, 5, 80, 35)];
    label4.text = @"精品";
    label4.backgroundColor = [UIColor clearColor];
    label4.textColor = [UIColor grayColor];
    label4.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label4];
    
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(45, 40, 80, 35)];
    label5.text = @"定期保养";
    label5.backgroundColor = [UIColor clearColor];
    label5.textColor = [UIColor grayColor];
    label5.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label5];
    
    UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(195, 40, 80, 35)];
    label6.text = @"一般修理";
    label6.backgroundColor = [UIColor clearColor];
    label6.textColor = [UIColor grayColor];
    label6.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label6];
    
    UILabel *label7 = [[UILabel alloc]initWithFrame:CGRectMake(335, 40, 80, 35)];
    label7.text = @"喷漆";
    label7.backgroundColor = [UIColor clearColor];
    label7.textColor = [UIColor grayColor];
    label7.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label7];
}
#pragma mark - 是否选择首次保养的回调
-(void)firstChoose:(id)sender
{
    if(_chooes1 == YES)
    {
        _chooes1 = NO;
        [self.firstChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes1 = YES;
        [self.firstChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes1]];
}
#pragma mark - 是否选择年检保养的回调
-(void)nJianChoose:(id)sender
{
    if(_chooes3 == YES)
    {
        _chooes3 = NO;
        [self.nJianChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes3 = YES;
        [self.nJianChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes3]];
}
#pragma mark - 是否选择钣金的回调
-(void)bJinChoose:(id)sender
{
    if(_chooes5 == YES)
    {
        _chooes5 = NO;
        [self.bJinChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes5 = YES;
        [self.bJinChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes5]];
}
#pragma mark - 是否选择精品的回调
-(void)jPinChoose:(id)sender
{
    if(_chooes7 == YES)
    {
        _chooes7 = NO;
        [self.jPinChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes7 = YES;
        [self.jPinChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes7]];
}
#pragma mark - 是否选择定期保养的回调
-(void)dQiChoose:(id)sender
{
    if(_chooes2 == YES)
    {
        _chooes2 = NO;
        [self.dQiChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes2 = YES;
        [self.dQiChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes2]];
}
#pragma mark - 是否选择一般修理的回调
-(void)yBanChoose:(id)sender
{
    if(_chooes4 == YES)
    {
        _chooes4 = NO;
        [self.yBanChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes4 = YES;
        [self.yBanChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes4]];
}
#pragma mark - 是否选择喷漆的回调
-(void)pQiChoose:(id)sender
{
    if(_chooes6 == YES)
    {
        _chooes6 = NO;
        [self.pQiChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes6 = YES;
        [self.pQiChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes6]];
}

-(void)fixedTitle
{
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(290, 20, 200, 40)];
    label.text = @"预约新增";
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor grayColor];
    label.font = [UIFont fontWithName:@"ArialMT" size:22];
    [self.view addSubview:label];
    
    UIImageView *imageline= [[UIImageView alloc]initWithFrame:CGRectMake(15, 60, 670, 2)];
    imageline.image = [UIImage imageNamed:@"红色分割线.png"];
    [self.view addSubview:imageline];
    
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(35, 90, 80, 30)];
    label1.text = @"预  约  号:";
    label1.backgroundColor = [UIColor clearColor];
    label1.textColor = [UIColor grayColor];
    label1.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label1];
    
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(35, 140, 80, 30)];
    label2.textColor = [UIColor grayColor];
    NSString*str2=@"*车牌号码:";
    NSMutableAttributedString*att2=[[NSMutableAttributedString alloc]initWithString:str2];
    [att2 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    label2.attributedText =att2;
    label2.backgroundColor = [UIColor clearColor];
    
    label2.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label2];
    
    self.chexingLabel = [[UILabel alloc]initWithFrame:CGRectMake(350, 190, 80, 30)];
    self.chexingLabel.text = @"车型:";
    self.chexingLabel.backgroundColor = [UIColor clearColor];
    self.chexingLabel.textColor = [UIColor grayColor];
    self.chexingLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:self.chexingLabel];
    
    self.chexiLabel = [[UILabel alloc]initWithFrame:CGRectMake(35, 190, 80, 30)];
    self.chexiLabel.text = @"车系:";
    self.chexiLabel.backgroundColor = [UIColor clearColor];
    self.chexiLabel.textColor = [UIColor grayColor];
    self.chexiLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:self.chexiLabel];
    
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(35, 240, 80, 30)];
    label3.textColor = [UIColor grayColor];
    NSString*str3=@"*客户名称:";
    NSMutableAttributedString*att3=[[NSMutableAttributedString alloc]initWithString:str3];
    [att3 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    label3.attributedText =att3;
    label3.backgroundColor = [UIColor clearColor];
    
    label3.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label3];
    
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(35, 320, 80, 30)];
    label4.text = @"备注:";
    label4.backgroundColor = [UIColor clearColor];
    label4.textColor = [UIColor grayColor];
    label4.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label4];
    
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(35, 320, 80, 30)];
    label5.text = @"修理类型:";
    label5.backgroundColor = [UIColor clearColor];
    label5.textColor = [UIColor grayColor];
    label5.font = [UIFont fontWithName:@"ArialMT" size:16];
    //[self.view addSubview:label5];
    
    UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(35, 410, 80, 30)];
    label6.text = @"预约类型:";
    label6.backgroundColor = [UIColor clearColor];
    label6.textColor = [UIColor grayColor];
    label6.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label6];
    
    UILabel *label7 = [[UILabel alloc]initWithFrame:CGRectMake(35, 460, 80, 30)];
     label7.textColor = [UIColor grayColor];
    NSString*str17=@"*预约时间:";
    NSMutableAttributedString*att17=[[NSMutableAttributedString alloc]initWithString:str17];
    [att17 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    label7.attributedText =att17;
    label7.backgroundColor = [UIColor clearColor];
    label7.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label7];
    
    
    UILabel *label20 = [[UILabel alloc]initWithFrame:CGRectMake(350, 460, 80, 30)];
    label20.textColor = [UIColor grayColor];
    NSString*str20=@"*维修分类:";
    NSMutableAttributedString*att20=[[NSMutableAttributedString alloc]initWithString:str20];
    [att20 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    label20.attributedText =att20;
    label20.backgroundColor = [UIColor clearColor];
    
    label20.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label20];
    
    UILabel *label8 = [[UILabel alloc]initWithFrame:CGRectMake(35, 510, 80, 30)];
    label8.text = @"登  记  人:";
    label8.backgroundColor = [UIColor clearColor];
    label8.textColor = [UIColor grayColor];
    label8.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label8];
    
    UILabel *label9 = [[UILabel alloc]initWithFrame:CGRectMake(350, 90, 80, 30)];
    label9.text = @"来源:";
    label9.backgroundColor = [UIColor clearColor];
    label9.textColor = [UIColor grayColor];
    label9.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label9];
    
    UILabel *label10 = [[UILabel alloc]initWithFrame:CGRectMake(350, 140, 80, 30)];
    label10.text = @"车  架  号:";
    label10.backgroundColor = [UIColor clearColor];
    label10.textColor = [UIColor grayColor];
    label10.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label10];
    
    UILabel *label11 = [[UILabel alloc]initWithFrame:CGRectMake(350, 240, 80, 30)];
    label11.textColor = [UIColor grayColor];
    NSString*str11=@"*联系电话:";
    NSMutableAttributedString*att11=[[NSMutableAttributedString alloc]initWithString:str11];
    [att11 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    label11.attributedText = att11;
    label11.backgroundColor = [UIColor clearColor];
    
    label11.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label11];
    
    UILabel *label12 = [[UILabel alloc]initWithFrame:CGRectMake(350, 410, 80, 30)];
     label12.textColor = [UIColor grayColor];
    NSString*str12=@"*服务顾问:";
    NSMutableAttributedString*att12=[[NSMutableAttributedString alloc]initWithString:str12];
    [att12 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    label12.attributedText =att12;
    label12.backgroundColor = [UIColor clearColor];
   
    label12.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label12];
    
    UILabel *label13 = [[UILabel alloc]initWithFrame:CGRectMake(350, 460, 80, 30)];
    label13.text = @"结束时间:";
    label13.backgroundColor = [UIColor clearColor];
    label13.textColor = [UIColor grayColor];
    label13.font = [UIFont fontWithName:@"ArialMT" size:16];
    //[self.view addSubview:label13];
    
    UILabel *label14 = [[UILabel alloc]initWithFrame:CGRectMake(350, 510, 80, 30)];
    label14.text = @"登记时间:";
    label14.backgroundColor = [UIColor clearColor];
    label14.textColor = [UIColor grayColor];
    label14.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label14];
}
//输入框的代理方法
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    NSCharacterSet *cs;
    cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS]invertedSet];
    NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];
    BOOL canChange = [string isEqualToString:filtered];
    return canChange;
}
-(void)toViewButton:(id)sender
{
    NSNotification *notification = [NSNotification notificationWithName:@"toView" object:nil];
    [[NSNotificationCenter defaultCenter]postNotification:notification];
}
-(void)addNotification
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(GetRepairCustomerListByPlateNumber:) name:SHABIZHAOSHAOFEI object:nil];
    //服务顾问
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getSaName:) name:GETSANAMELIST object:Nil];
    //预约新增
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addPrecontractManage:) name:ADDPRECONTRACTMANAGE object:Nil];
    //工位
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getworkStationListOne:) name:GETWORKSTATIONLIST object:Nil];
}
-(void)removeNotification
{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}

@end
